package com.emm.yixun.openapi.hander;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.emm.yixun.common.app.GetProjectBusinessListReqDto;
import com.emm.yixun.common.app.GetProjectBusinessListResDto;
import com.emm.yixun.customer.service.app.CustomerServiceAppFacade;
import com.emm.yixun.openapi.dto.base.BaseRequestDTO;
import com.emm.yixun.openapi.dto.base.BaseResponseDTO;
import com.emm.yixun.openapi.vo.GetProjectBusinessListReqVo;

/**
 * 查询项目下业务列表接口
 * @author Administrator
 *
 */
@Service("getProjectBusinessListHander")
public class GetProjectBusinessListHander extends com.emm.yixun.openapi.hander.base.CommonAbstractHander{
	
	@Autowired
	private CustomerServiceAppFacade customerServiceAppFacade;
	
	@Autowired
	private CacheManager cacheManager;
	
	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		GetProjectBusinessListReqVo req = (GetProjectBusinessListReqVo)reqDto;
		GetProjectBusinessListReqDto reqDto1 = req.getParams();
		BaseResponseDTO<GetProjectBusinessListResDto> res = new BaseResponseDTO<GetProjectBusinessListResDto>();
		res.setResData(customerServiceAppFacade.getProjectBusinessList(reqDto1));
		//缓存projectId
		Cache  cache = cacheManager.getCache("activeSessionsCache");
		String projectId_key = reqDto1.getMerchantId()+reqDto1.getUserId()+"projectId";//组装projectId缓存key
		Element elment_projectId = new Element(projectId_key,res.getResData().getProjectId());
		cache.put(elment_projectId);
		return res;
	}
	
}
